/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 * */

// AmzServer - Tototoy's server model.
// Author: tonyjobmails@gmail.com (tonyhack).
//
// Define class TCPPacketSocketCommunicator.
//
// TCPPacketSocketCommunicator uses to send/receive TCP packet data. Each
// send will be a packet, and each receive will be a packet.
// This socket communicator uses 2 buffer to store the redundant data witch is
// beyond socket's the ablity. So, in theory the data's sending/receiving will be
// not immediately.
//

#ifndef __TCP__PACKET__SOCKET__COMMUNICATOR__H
#define __TCP__PACKET__SOCKET__COMMUNICATOR__H

#include "tcp_socket_communicator.h"
#include "byte_buffer_dynamic.h"

namespace amz {

class TCPPacketSocketCommunicator : public TCPSocketCommunicator {
 public:
  TCPPacketSocketCommunicator(int socket,
         CompressType compress, EncryptType encrypt);
  virtual ~TCPPacketSocketCommunicator();

  // Receive.
  virtual int Receive(char *message, int max_size);
  // Send.
  virtual int Send(char *message, int size);

 protected:
  // This 2 buffer is to store the part witch is beyond socket's the ablity.
  ByteBufferDynamic packet_receive_;
  ByteBufferDynamic packet_send_;
};

}  // namespace amz

#endif  // __TCP__PACKET__SOCKET__COMMUNICATOR__H
